package com.pp.service.impl;

import com.pp.bean.User;
import com.pp.mapper.UserMapper;
import com.pp.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.util.*;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 张子艺
 * @since 2019-03-06
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Override
    public boolean login(String userName, String passWord, HttpSession session) {
        Map map=new HashMap();
        map.put("account",userName);
        map.put("pass",passWord);
        Collection list=this.listByMap(map);
        if(list.size()>0){
            session.setAttribute("user",new ArrayList<>(list).get(0));
            return true;
        }else{
            return  false;
        }

    }
}
